package com.wuage.interfaces.account;

import com.wuage.application.IUacAccountService;
import com.wuage.domain.model.UacAccount;
import com.wuage.infrastructure.utils.Response;
import com.wuage.interfaces.account.domain.RegisterAdminDO;
import com.wuage.interfaces.account.vo.AccountVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.validation.Valid;
import java.util.List;

/**
 * @author Shynin
 * @version 1.0
 * @date 9/28/21 10:55 AM
 */
@Api(tags = "超级管理员-{管理员}操作相关接口")
@RestController
@RequestMapping("/superAdmin")
public class SuperAdminController {

    @Resource
    private IUacAccountService uacAccountService;


    @GetMapping("/admin")
    @ApiOperation("查询管理员列表")
    public Response<List<AccountVO>> getAdmin() {
        List<UacAccount> accounts = uacAccountService.getAdmins();
        return Response.success(AccountVO.assembleAccounts2Vos(accounts));
    }


    @PostMapping("/admin")
    @ApiOperation("创建管理员")
    public Response<Boolean> addAdmin(@RequestBody @Valid RegisterAdminDO registerAdminDO) {
        Boolean result = uacAccountService.addAdmin(registerAdminDO);
        return Response.success(result);
    }

}
